// ProgramPearl3_5.cpp : Defines the entry point for the console application.
//
#include "stdafx.h" 
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iterator>
#include<iostream>

using namespace std;
#define MAX 10;

char* pp[24] = {"et-ic", "al-is-tic", "s-tic", "p-tic", "-lyt-ic", "ot-ic", "an-tic",
"n-tic", "c-tic", "at-ic", "h-nic", "n-ic", "m-ic", "l-lic", "b-lic", "-clic", "l-ic",
"h-ic", "f-ic", "d-ic", "-bic", "a-ic", "-mac", "i-ac"};

int IsEqual(const char* a, const char *b);
char* reverseString(char * p);

int main()
{
	char p[24][10];
	
	for(int i = 0; i < 24; i++)
	{
		strcpy(p[i],pp[i]);
		reverseString(p[i]);
	}
//	qsort(a,24,sizeof(struct affix),cmp);
	char find[10] = "eth-nic";
	cout << p[10] << endl;
	reverseString(find);
	cout << find << endl;
	for( i = 0; i < 24; i++)
	{
		if(IsEqual(find,p[i]))
			break;
	}
	cout << i << endl;

	return 0;
}


char* reverseString(char * p)
{
	int n = strlen(p);
	char temp;

	for(int i = 0; i <= (n/2); i++)
	{
		temp = p[i];
		p[i] = p[n-1-i];
		p[n-1-i] = temp;
	}
	return p;
}

int IsEqual(const char* a, const char *b)
{
	
	for(int i = 0; i < strlen(b); i++)
	{
		if((b[i] != a[i]) || (a[i] == '\0'))
			break;
	}
	if(i == strlen(b))
		return 1;
	else return 0;
}
